package io.adrainty.bolee.framework.commons.basic;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 统一响应封装
 *
 * @author adrainty
 * @version v1.0.0
 * @since 2023/12/12 17:28
 */
@Data
@Builder
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@SuppressWarnings("unused")
public class ResultDTO<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = -6657950320126095077L;

    @Schema(description = "状态码")
    private int code;

    @Schema(description = "数据")
    private T data;

    @Schema(description = "错误消息")
    private String msg;

    @Schema(description = "时间戳")
    private LocalDateTime timestamp;

    @Schema(description = "是否成功")
    private Boolean success;

    @Schema(description = "操作人Id")
    private Long operatorId;

    @Schema(description = "操作人名称")
    private String operatorName;

    public ResultDTO() {
        this.timestamp = LocalDateTime.now();
    }

}
